import request from "@/utils/request";

// 获取商品列表
export function getProductList(name) {
  return request({
    url: `/product?name=${name}`,
    method: "get",
  });
}

// 获取商品分类列表
export function getCategoryList() {
  return request({
    url: "/product-category",
    method: "get",
  });
}

// 获取品牌列表
export function getBrandList() {
  return request({
    url: "/product-brand",
    method: "get",
  });
}

// 获取供应商列表
export function getSupplierList() {
  return request({
    url: "/supplier",
    method: "get",
  });
}

// 获取计量单位列表
export function getUnitList() {
  return request({
    url: "/product-unit",
    method: "get",
  });
}

// 获取产地列表
export function getOriginList() {
  return request({
    url: "/product-origin",
    method: "get",
  });
}

// 获取仓库列表
export function getWarehouseList() {
  return request({
    url: "/warehouse",
    method: "get",
  });
}

// 文件上传
export function uploadFile(data) {
  return request({
    url: "/file/upload",
    method: "post",
    headers: {
      "Content-Type": "multipart/form-data",
    },
    data,
  });
}

// 删除文件
export function deleteFile(fileName) {
  return request({
    url: `/file/${fileName}`,
    method: "delete",
  });
}

// 批量删除文件
export function deleteFiles(fileNames) {
  return request({
    url: "/file",
    method: "delete",
    data: fileNames,
  });
}
